﻿using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.Chat;

#pragma warning disable SKEXP0110

namespace CodeAgent.Host.Agents;

public class AgentTerminationStrategy(List<ChatMessageContent> chatHistory) : TerminationStrategy
{
    protected override Task<bool> ShouldAgentTerminateAsync(Agent agent, IReadOnlyList<ChatMessageContent> history,
        CancellationToken cancellationToken)
    {
        if (history.Any(x => x.Content?.Contains("[done]") == true))
        {
            return Task.FromResult(true);
        }

        chatHistory.AddRange(history);

        return Task.FromResult(false);
    }
}